﻿using System;
using System.Collections.Generic;
using System.Text;
using WindowsLive.Writer.Api;
using System.Windows.Forms;
using System.IO;
using Danielyan.Exif;

namespace WindStyle.WindowsLiveWriter.Plugin.ExifInfo
{
    [WriterPlugin("60FBA46B-B877-4178-9B6C-3D2444623C4A",
        "ExifInfo",
        PublisherUrl = "http://coding.windstyle.cn",
        Description = "Insert pictures with Exif info.\n插入图片时同时插入图片的Exif信息。",
        ImagePath = "Resources.ExifInfo.png",
        HasEditableOptions = true)]
    [InsertableContentSource("ExifInfo")]
    public class ExifInfoPlugin : ContentSource
    {
        public override void Initialize(IProperties pluginOptions)
        {
            base.Initialize(pluginOptions);
            Option.Load(pluginOptions);
        }
        public override void EditOptions(IWin32Window dialogOwner)
        {
            OptionForm optionForm = new OptionForm();
            optionForm.ShowDialog();
        }

        public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = true;
            DialogResult result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                foreach (string file in dialog.FileNames)
                {
                    content += Utilities.GetExifInfoString(file);
                }
            }
            return result;
        }
    }
}
